package com.ssy.lingxi.contract.config;

import com.ssy.lingxi.component.redis.service.IRedisUtils;
import com.ssy.lingxi.contract.esign.token.EsignCache;


/**
 * esign缓存
 * @author yzc
 * @version 2.0.0
 * @date 2021/7/24
 */
public class RedisEsignCache implements EsignCache {

    private final IRedisUtils redisUtils;
    private final Integer dbIndex;

    public RedisEsignCache(IRedisUtils redisUtils, Integer dbIndex) {
        this.redisUtils = redisUtils;
        this.dbIndex = dbIndex;
    }

    @Override
    public Object get(String key) {
        return redisUtils.get(key, dbIndex);
    }

    @Override
    public boolean put(String key, Object obj, long expire) {
        long seconds = expire / 1000;
        return redisUtils.set(key, obj, seconds, dbIndex);
    }
}
